home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 108 / MacAddict108.iso / Software / Internet & Communication / WordPress 1.5.1.dmg / wordpress / wp-links-opml.php < prev    next >
Encoding:
PHP Script  |  2005-03-23  |  2.3 KB  |  58 lines

  1. <?php 
  2. $doing_rss = 1;
  3.  
  4. require('wp-blog-header.php');
  5. header('Content-type: text/xml; charset=' . get_settings('blog_charset'), true);
  6. $link_cat = $_GET['link_cat'];
  7. if ((empty($link_cat)) || ($link_cat == 'all') || ($link_cat == '0')) {
  8.     $sql_cat = '';
  9. } else { // be safe
  10.     $link_cat = ''.urldecode($link_cat).'';
  11.     $link_cat = addslashes_gpc($link_cat);
  12.     $link_cat = intval($link_cat);
  13.     if ($link_cat != 0) {
  14.         $sql_cat = "AND $wpdb->links.link_category = $link_cat";
  15.         $cat_name = $wpdb->get_var("SELECT $wpdb->linkcategories.cat_name FROM $wpdb->linkcategories WHERE $wpdb->linkcategories.cat_id = $link_cat");
  16.         if (!empty($cat_name)) {
  17.             $cat_name = ": category $cat_name";
  18.         }
  19.     }
  20. }
  21. ?><?php echo '<?xml version="1.0"?'.">\n"; ?>
  22. <!-- generator="wordpress/<?php echo $wp_version ?>" -->
  23. <opml version="1.0">
  24.     <head>
  25.         <title>Links for <?php echo get_bloginfo('name').$cat_name ?></title>
  26.         <dateCreated><?php echo gmdate("D, d M Y H:i:s"); ?> GMT</dateCreated>
  27.     </head>
  28.     <body>
  29. <?php $sql = "SELECT $wpdb->links.link_url, link_rss, $wpdb->links.link_name, $wpdb->links.link_category, $wpdb->linkcategories.cat_name, link_updated 
  30. FROM $wpdb->links 
  31.  JOIN $wpdb->linkcategories on $wpdb->links.link_category = $wpdb->linkcategories.cat_id
  32.  $sql_cat
  33.  ORDER BY $wpdb->linkcategories.cat_name, $wpdb->links.link_name \n";
  34.  //echo("<!-- $sql -->");
  35.  $prev_cat_id = 0;
  36.  $results = $wpdb->get_results($sql);
  37.  if ($results) {
  38.      foreach ($results as $result) {
  39.          if ($result->link_category != $prev_cat_id) { // new category
  40.              if ($prev_cat_id != 0)  { // not first time
  41. ?>
  42.         </outline>
  43. <?php
  44.              } // end if not first time
  45. ?>
  46.         <outline type="category" title="<?php echo wp_specialchars($result->cat_name); ?>">
  47. <?php
  48.              $prev_cat_id = $result->link_category;
  49.         } // end if new category
  50. ?>
  51.             <outline title="<?php echo wp_specialchars($result->link_name); ?>" type="link" xmlUrl="<?php echo wp_specialchars($result->link_rss); ?>" htmlUrl="<?php echo wp_specialchars($result->link_url); ?>" updated="<?php if ('0000-00-00 00:00:00' != $result->link_updated) echo $result->link_updated; ?>" />
  52. <?php
  53.         } // end foreach
  54.     } // end if
  55. ?>
  56.         </outline>
  57.     </body>
  58. </opml>